<?php
use GatewayClient\Gateway;
?>
<div class="maintop">
    当前位置：红包游戏玩法管理
    <a href="javascript:;" action="<?=$basepath?>_add" class="mainFrame button icon-plus">添加新玩法</a>
    <a href="javascript:;" action="<?=$basepath?>" class="mainFrame button">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
    <a href="/cache/update?key=games_list_and_item" class="button" target="ajax" func="loadpage">更新缓存</a>
</div>
<div class="main-search">
    <table width="100%">
        <tbody><tr>
            <td>
                <form action="<?=$basepath?>" id="SearchForm" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                    <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字">
                    每页：
                    <select id="ps" name="ps">
                        <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                        <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                        <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                        <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                        <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                    </select>
                    <input type="submit" value="搜索" class="upbutton">
                    <input action="<?=$basepath?>_delete_list" type="button" id="deleteSelectId" value="删除选择" class="upbutton">
                </form>
            </td>
        </tr>
        </tbody>

    </table>
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg"><th width="30"><input id="selectAllid" type="checkbox" value="1" /></th>
            <th width="40">No.</th>
            <th>名称</th>
            <th>图标</th>
            <th>算法</th>
            <th width="40">赔率</th>
            <th>参与费用</th>
            <th>创建费用</th>
            <th>口令费用</th>
            <th>最小投注</th>
            <th>最大投注</th>
            <th>抢发参数</th>
            <th>在线</th>
            <th>排序</th>
            <th width="60">操作</th>
        </tr>
        <? foreach($datas as $v){ ?>
            <tr<?=($v['state']?'':' class="delete"')?>>
                <td width="30"><input type="checkbox" name="selectValue" value="<?=$v['id']?>" /></td>
                <td><?=$v['id']?></td>
                <td><?=$v['title']?></td>
                <td><img src="<?=$this->config['imgsurl']?>/<?=$v['icon']?>" style="height:20px" /></td>
                <td><?=$v['func']?></td>
                <td><a href="javascript:void(0)" action="/games/games_odds_set?gameid=<?=$v['id']?>&gamename=<?=$v['title']?>" class="mainFrame button">设置</a></td>
                <td><?=$v['establishcost']?></td>
                <td><?=$v['establishcoin']?></td>
                <td><?=$v['passcoin']?></td>
                <td><?=$v['minbetcoin']?></td>
                <td><?=$v['maxbetcoin']?></td>
                <td><a href="javascript:void(0)" action="/games/games_setup?gameid=<?=$v['id']?>&gamename=<?=$v['title']?>" class="mainFrame button" style="float:initial">设置</a></td>
                <td><a href="javascript:void(0)" action="/members/onlineuserlist?type=game_<?=$v['id']?>" class="mainFrame"><?=(count(Gateway::getClientSessionsByGroup("game_".$v['id'])))?></a></td>
                <td><?=$v['sort']?></td>
                <td>
                    <a action="<?=$basepath?>_state?id=<?=$v['id']?>" title="恢复" class="mainFrame button icon-undo" href="javascript:;"></a>
                    <a action="<?=$basepath?>_edit?id=<?=$v['id']?>" title="编辑" class="mainFrame button icon-edit" href="javascript:;"></a>
                </td>
            </tr>
        <? } ?>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){

    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['usergroup'])){
            echo '$("#usergroup option[value='.$searchdata['usergroup'].']").attr("selected", "selected");';
        }
        ?>
    });
</script>
